/**
 * Created by seeker910 on 2017/6/11.
 * 包含：日期和时间
 * 输入值为 int型
 * 返回 类型与输入值类型一致，为 int型。
 * 该控件用于 对timestamp值 使用用int 类型存储对数据
 */
Rsd.define('Rsd.form.Slider', {
    extend: 'Rsd.form.Input',
    xtype: 'slider',
    inputType: 'range', 
    min:0,
    max:100, 
    ctrlCls:'x-slider',
    /**
     * 
     * @param {*} config 
     */
    constructor: function Silder(config) {
        config = config || {};
        this.apply(config);
    },
    /**
     * 
     */
    initComponentEx: function initComponentEx() {
        var me = this;
        this.callParent();
        
        this.___txt = document.createElement('span');
        this.___txt.style.width= '40px';
        this.___txt.style.textAlign = 'center';
        this.___txt.style.alignItems = 'center';
       
    },
    /**
     * 
     */
    onAfterInit: function onAfterInit() {
       
        this.callParent();
        
        var me = this;
        if(me.min != undefined && me.min != null)
        {
            me.ctrl.element.setAttribute("min",this.min);
        }
        if(me.max != undefined && me.max != null)
        {
            me.ctrl.element.setAttribute("max",this.max);
        }
       
        me.ctrl.element.onchange = function(evt)
        {
            me.___txt.innerText = this.value;
            me.funApplyByIOC(me.onchange||me.valueChanged||me.textChanged,[me,evt]);
        
        }
       
    },
    /**
     * 追加组件
     */
    onAfterRender:function onAfterRender()
    {
        this.callParent();  
        this.dom.appendChild(this.___txt);
    },
    /**
     * 
     * @param {*} value 
     */
    setValue:function setValue(value) {

        var _v = parseFloat(value).toFixed(0);
        this.callParent(_v);
    },
    /**
     * 
     * @returns 
     */
    getValue:function getValue()
    {
        var me = this;
        var _v = me.callParent();
        return Rsd.isEmpty(_v)?0: Number(_v);
    }

});